<template>
  <div>
    <el-table v-loading="loading" :data="logData" style="width: 100%">
      <el-table-column type="index" :index="1" label="序号" width="180" />
      <el-table-column prop="realname" label="姓名" width="180" />
      <el-table-column prop="method" label="访问方式" />
      <el-table-column prop="content" label="访问路径" />
      <el-table-column prop="logTime" label="访问时间">
        <template v-slot="{ row }">
          <span>{{ row.logTime | fmtDate }}</span>
        </template>
      </el-table-column>
    </el-table>
    <div class="page">
      <el-pagination
        :current-page="params.page"
        :page-sizes="[2, 5, 10, 20]"
        :page-size="params.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
import { get, post } from '@/utils/request'
import { fmtDate } from '@/filters/index'

export default {
  filters: { fmtDate },
  data() {
    return {
      logData: [],
      params: {
        page: 1,
        pageSize: 10
      },
      total: 0,
      loading: false
    }
  },
  computed: {},
  created() {
    // this.$store.dispatch('log/queryLogs',{page:1,pageSize:1000})
    this.checkLogs()
  },
  mounted() {},
  methods: {
    async checkLogs() {
      const res = await get('/baseLog/pageQuery', this.params)
      this.logData = res.data.list
      this.total = res.data.total
    },
    handleSizeChange(pageSize) {
      this.params.pageSize = pageSize
      this.params.page = 1
      this.checkLogs()
    },
    handleCurrentChange(page) {
      this.params.page = page
      this.checkLogs()
    }
  }
}
</script>
<style scoped>
</style>
